/*
 * This file is part of FinVis.
 *
 * FinVis is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * FinVis is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with FinVis.  If not, see <http://www.gnu.org/licenses/>
 *
 * @author Stephen Rudolph
 */

#ifndef FIN_VIEW_H
#define FIN_VIEW_H

#include <QWidget>
#include <QDate>
#include <vector>
#include "Common.h"
#include "FinInvestment.h"

class QStandardItemModel;
class QTableView;

class FinView : public QWidget
{
    Q_OBJECT
public:
    enum display {DEFAULT_VIEW, LIQUID_ASSETS, TABLE_VIEW, SIMPLE_VIEW, MINI_VIEW, OPTIMISTIC_ONLY,
                  PESSIMISTIC_ONLY, MINI_VIEW_OPTIMISTIC_ONLY, MINI_VIEW_PESSIMISTIC_ONLY};
    FinView(enum display displayType, QWidget *parent = 0);
    void reset();
    QSize minimumSizeHint() const;
    QSize sizeHint() const;
public slots:
    void portfolioChanged();
    void increasePlotBounds();
    void decreasePlotBounds();
    int drawSampleOutcome();
    int drawFinalOutcome();
    void drawOutcome(int sampleOutcome);
    void enableSymbol(enum::symbols symbol);
    void disableSymbol(enum::symbols symbol);
protected:
    void paintEvent(QPaintEvent *event);
    void mousePressEvent(QMouseEvent *event);
private:
    int drawOutcome(bool finalResult);
    void transformPainterForGraph(QPainter *painter);

    QPalette defaultPalette;
    QSize widgetSize;
    QStandardItemModel *model, *riskModel;
    QTableView *wealthTableView, *riskTableView;

    void drawBox(QPainter *painter);
    void drawAxes(QPainter *painter);
    void drawAxesLabels(QPainter *painter);
    void plotInvestments(QPainter *painter);
    void plotLiquidAssets(QPainter *painter);

    int minBound, maxBound, sidePaneWidth, topPaneHeight, bottomPaneHeight;
    enum display displayType;
    bool sampleOutcomeShown, showGradient, showSelected, showUnselected,
        showLiquidAssets, showBoundary, showResult;
    double sampleOutcome;
};

#endif
